package com.jt.controller;

import com.jt.pojo.Car;
import com.jt.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Car")
@CrossOrigin
public class CarController {
    @Autowired
    private CarService service;

    @GetMapping("/getAll")
    public List<Car> getAll(){
        return service.getAll();
    }

    @DeleteMapping("/deletecar")
    public String deleteCar(Integer id){
        service.deleteCar(id);
        return "删除成功";
    }

    @PostMapping("/savecar")
    public String savecar(@RequestBody Car car){
        service.savecar(car);
        return "插入成功";
    }

    @PutMapping("/updatecar")
    public String updateCar(@RequestBody Car car){
        service.updateCar(car);
        return "更改成功";
    }
}
